home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / query / mquery / mgrid.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-05-24  |  18.4 KB  |  626 lines

  1. VERSION 2.00
  2. Begin Form fGridFrm 
  3.    BackColor       =   &H00C0C0C0&
  4.    ClientHeight    =   3135
  5.    ClientLeft      =   1455
  6.    ClientTop       =   2640
  7.    ClientWidth     =   6675
  8.    ClipControls    =   0   'False
  9.    Height          =   3540
  10.    Icon            =   MGRID.FRX:0000
  11.    Left            =   1395
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3125.913
  14.    ScaleMode       =   0  'User
  15.    ScaleWidth      =   6692.959
  16.    Tag             =   "Dynaset"
  17.    Top             =   2295
  18.    Width           =   6795
  19.    Begin Grid cGrid 
  20.       Height          =   2715
  21.       Left            =   0
  22.       TabIndex        =   9
  23.       Top             =   420
  24.       Width           =   6675
  25.    End
  26.    Begin PictureBox ViewButtons 
  27.       BackColor       =   &H00C0C0C0&
  28.       BorderStyle     =   0  'None
  29.       Height          =   375
  30.       Left            =   0
  31.       ScaleHeight     =   372
  32.       ScaleMode       =   0  'User
  33.       ScaleWidth      =   5171.607
  34.       TabIndex        =   0
  35.       Top             =   24
  36.       Width           =   5175
  37.       Begin CommandButton SortButton 
  38.          Caption         =   "&Sort"
  39.          Height          =   372
  40.          Left            =   3720
  41.          TabIndex        =   8
  42.          Top             =   0
  43.          Width           =   612
  44.       End
  45.       Begin CommandButton FilterButton 
  46.          Caption         =   "Fil&ter"
  47.          Height          =   372
  48.          Left            =   3120
  49.          TabIndex        =   7
  50.          Top             =   0
  51.          Width           =   612
  52.       End
  53.       Begin CommandButton RefreshButton 
  54.          Caption         =   "&Redo"
  55.          Height          =   372
  56.          Left            =   2520
  57.          TabIndex        =   6
  58.          Top             =   0
  59.          Width           =   612
  60.       End
  61.       Begin CommandButton CloseButton 
  62.          Cancel          =   -1  'True
  63.          Caption         =   "&Close"
  64.          Height          =   372
  65.          Left            =   4320
  66.          TabIndex        =   5
  67.          Top             =   0
  68.          Width           =   612
  69.       End
  70.       Begin CommandButton MoreButton 
  71.          Caption         =   "&More"
  72.          Height          =   372
  73.          Left            =   1320
  74.          TabIndex        =   4
  75.          Top             =   0
  76.          Width           =   612
  77.       End
  78.       Begin CommandButton NextButton 
  79.          Caption         =   "&Next"
  80.          Height          =   372
  81.          Left            =   120
  82.          TabIndex        =   3
  83.          Top             =   0
  84.          Width           =   612
  85.       End
  86.       Begin CommandButton FirstButton 
  87.          Caption         =   "&First"
  88.          Height          =   372
  89.          Left            =   720
  90.          TabIndex        =   2
  91.          Top             =   0
  92.          Width           =   612
  93.       End
  94.       Begin CommandButton FindButton 
  95.          Caption         =   "F&ind"
  96.          Height          =   372
  97.          Left            =   1920
  98.          TabIndex        =   1
  99.          Top             =   0
  100.          Width           =   612
  101.       End
  102.    End
  103. Option Explicit
  104. 'form variables
  105. 'Dim FDS As dynaset         'current form's dynaset
  106. Dim FDS As snapshot        'current form's snapshot
  107. Dim FDynSt As String       'dynaset open string
  108. Dim FTblname As String     'form dynaset table name
  109. Dim FCurrentRow As Long    'current row in dynaset
  110. Dim FGridRow As Integer    'current grid row
  111. Dim FNotFound As Integer   'find not found flag
  112. Dim FFindForm As New fFind 'find form
  113. Dim FNumbRows As Long      'total number of rows in table
  114. Dim FDynaString As String  'dynaset open string
  115. Sub cGrid_DblClick ()
  116.   Dim r As Integer       'return from execute sql
  117.   Dim fn As String       'field name
  118.   On Error GoTo ZoomErr
  119.   r = cGrid.Row
  120.   cGrid.Row = 0
  121.   'get field name
  122.   fn = cGrid.Text
  123.   cGrid.Row = r
  124.   'make sure it's a string or memo field
  125.   'If FDS(fn).Type = FT_STRING Or FDS(fn).Type = FT_MEMO Then
  126.     ' gstZoomData = cGrid.Text
  127.     ' fZoom.Caption = fn
  128.     ' fZoom.Top = Top + 1200
  129.     ' fZoom.Left = Left + 250
  130.     ' fZoom.CloseZoomButton.Visible = True
  131.      'fZoom.Show MODAL
  132.   'End If
  133.   GoTo ZoomEnd
  134. ZoomErr:
  135.   ShowError
  136.   Resume ZoomEnd
  137. ZoomEnd:
  138. End Sub
  139. Sub cGrid_KeyUp (KeyCode As Integer, Shift As Integer)
  140.   'zoom on F4 key press
  141.   If KeyCode = &H73 Then   'F4
  142.     cGrid_DblClick
  143.   End If
  144. End Sub
  145. Sub CloseButton_Click ()
  146.   If Not gStoredFlag Then ' this query did not come from storage
  147.     fQuery.RunSaveQryButton.Caption = "&Store Query "
  148.     fQuery.RunSaveQryButton.Enabled = True
  149.     fQuery.RunQueryButton.Enabled = False
  150.     Else
  151.     fQuery.RunSaveQryButton.Caption = "&Load Query"
  152.     fQuery.RunSaveQryButton.Enabled = False
  153.     fQuery.RunQueryButton.Enabled = False
  154.     'gStoredFlag = False
  155.   End If
  156.   fQuery.Show
  157.   Unload Me
  158. End Sub
  159. Sub FilterButton_Click ()
  160.   On Error GoTo FilterErr
  161. '  Dim ds1 As dynaset, ds2 As dynaset
  162.   Dim ds1 As snapshot, ds2 As snapshot
  163.   'Dim gFilterStr As String
  164.   Dim numbrows As Long    'local number of rows
  165.   Set ds1 = FDS            'save the dynaset
  166.    Dim i As Integer, r As Integer, c As Integer
  167.    'On Error GoTo FindErr
  168.    'load the column names into the filter form
  169.    'the 1st time it is loaded
  170.      fFilter.cExpr.Text = ""
  171.      fFilter.cFieldList.Clear
  172.      r = cGrid.Row
  173.      c = cGrid.Col
  174.      cGrid.Row = 0
  175.      cGrid.Col = 0
  176.      For i = 1 To cGrid.Cols - 1
  177.        cGrid.Col = cGrid.Col + 1
  178.        fFilter.cFieldList.AddItem cGrid.Text
  179.      Next
  180.      cGrid.Row = r
  181.      cGrid.Col = c
  182.    MsgBar "Enter Search Parameters without quotes", False
  183.   fFilter.Show MODAL
  184.   'gFilterStr = InputBox("Enter Filter Expression:")
  185.   If gFilterStr = "" Then Exit Sub
  186.   FDS.Filter = gFilterStr
  187. '  Set ds2 = FDS.CreateDynaset()            'establish the filter
  188.   Set ds2 = FDS.CreateSnapshot()            'establish the filter
  189.   Set FDS = ds2            'assign back to original dynaset object
  190.   'everything must be okay so redisplay form on 1st record
  191.   FNumbRows = GetNumbRecsSS(FDS)          'query numb of recs
  192.    If FNumbRows = -1 Then
  193.      'error occurred but go on anyway
  194.      'because row count is non-critical
  195.      Caption = "Dynaset: " + FTblname
  196.      numbrows = gwMaxGridRows
  197.      FCurrentRow = numbrows
  198.    ElseIf FNumbRows = 0 Then
  199.      Beep
  200.      MsgBox "No Records found!", 48
  201.      ResetMouse Me
  202.      Unload Me
  203.      fQuery.Show
  204.      Exit Sub
  205.    ElseIf FNumbRows > gwMaxGridRows Then
  206.      Caption = "Dynaset: " + FTblname + " [" + CStr(FNumbRows) + " total rows]"
  207.      numbrows = gwMaxGridRows
  208.      FCurrentRow = numbrows
  209.    Else
  210.      numbrows = FNumbRows
  211.      Caption = "Dynaset: " + FTblname + " [" + CStr(FNumbRows) + " rows]"
  212.    End If
  213.   If LoadGrid(cGrid, FDS, FDynSt, numbrows, 0) = False Then
  214.     Unload Me
  215.     fQuery.Show
  216.     Exit Sub
  217.   End If
  218.   GoTo FilterEnd
  219. FilterErr:
  220.   ShowError
  221.   Set FDS = ds1            're-assign back to original
  222.   Resume FilterEnd
  223. FilterEnd:
  224. End Sub
  225. Sub FindButton_Click ()
  226.    Dim i As Integer, r As Integer, c As Integer
  227.    On Error GoTo FindErr
  228.    'load the column names into the find form
  229.    'the 1st time it is loaded
  230.    If FFindForm.cFieldList.ListCount = 0 Then
  231.      FFindForm.cFieldList.Clear
  232.      r = cGrid.Row
  233.      c = cGrid.Col
  234.      cGrid.Row = 0
  235.      cGrid.Col = 0
  236.      For i = 1 To cGrid.Cols - 1
  237.        cGrid.Col = cGrid.Col + 1
  238.        FFindForm.cFieldList.AddItem cGrid.Text
  239.      Next
  240.      cGrid.Row = r
  241.      cGrid.Col = c
  242.    End If
  243. FindStart:       'used to loop around on not found
  244.    'reset the flags
  245.    gfFindFailed = False
  246.    gfFromTableView = True
  247.    MsgBar "Enter Search Parameters", False
  248.    FFindForm.Show MODAL
  249.    MsgBar "Searching for record", True
  250.    If gfFindFailed = True Then Exit Sub
  251.    FNotFound = False
  252.    SetHourGlass Me
  253.    'search for the record
  254.    cGrid.SetFocus        'start at the top
  255.    SendKeys "^{Home}"
  256.    cGrid.Col = 1
  257.    cGrid.Row = 0
  258.    'move the right column
  259.    While cGrid.Text <> UCase(gstFindField)
  260.      If cGrid.Col = cGrid.Cols Then 'reached max col
  261.      Else
  262.        cGrid.Col = cGrid.Col + 1
  263.        SendKeys "{Right}"
  264.      End If
  265.    Wend
  266.    cGrid.Row = 1
  267.    While cGrid.Row < cGrid.Rows - 1
  268.        If gfFindMatch = False Then
  269.          Select Case gstFindOp
  270.            Case "="
  271.              If UCase(cGrid.Text) = UCase(gstFindExpr) Then GoTo AfterWhile
  272.            Case "<>"
  273.              If UCase(cGrid.Text) <> UCase(gstFindExpr) Then GoTo AfterWhile
  274.            Case ">="
  275.              If UCase(cGrid.Text) >= UCase(gstFindExpr) Then GoTo AfterWhile
  276.            Case "<="
  277.              If UCase(cGrid.Text) <= UCase(gstFindExpr) Then GoTo AfterWhile
  278.            Case ">"
  279.              If UCase(cGrid.Text) > UCase(gstFindExpr) Then GoTo AfterWhile
  280.            Case "<"
  281.              If UCase(cGrid.Text) < UCase(gstFindExpr) Then GoTo AfterWhile
  282.            Case "Like"
  283.              If UCase(cGrid.Text) Like UCase(gstFindExpr) Then GoTo AfterWhile
  284.          End Select
  285.        Else
  286.          Select Case gstFindOp
  287.            Case "="
  288.              If cGrid.Text = gstFindExpr Then GoTo AfterWhile
  289.            Case "<>"
  290.              If cGrid.Text <> gstFindExpr Then GoTo AfterWhile
  291.            Case ">="
  292.              If cGrid.Text >= gstFindExpr Then GoTo AfterWhile
  293.            Case "<="
  294.              If cGrid.Text <= gstFindExpr Then GoTo AfterWhile
  295.            Case ">"
  296.              If cGrid.Text > gstFindExpr Then GoTo AfterWhile
  297.            Case "<"
  298.              If cGrid.Text < gstFindExpr Then GoTo AfterWhile
  299.            Case "Like"
  300.              If cGrid.Text Like gstFindExpr Then GoTo AfterWhile
  301.          End Select
  302.        End If
  303.      cGrid.Row = cGrid.Row + 1
  304.      SendKeys "{Down}"
  305.    Wend
  306.    FNotFound = True       'didn't find it
  307. AfterWhile:
  308.    ResetMouse Me
  309.    'show the first record
  310.    If FNotFound Then
  311.      Beep
  312.      MsgBox "Record Not Found", 48
  313.      GoTo FindStart
  314.    End If
  315.    DoEvents
  316.    cGrid.SelStartRow = cGrid.Row
  317.    cGrid.SelStartCol = 1
  318.    cGrid.SelEndRow = cGrid.Row
  319.    cGrid.SelEndCol = FDS.Fields.Count
  320.    GoTo FindEnd
  321. FindErr:
  322.    ResetMouse Me
  323.    ShowError
  324.    Resume FindEnd
  325. FindEnd:
  326.    MsgBar "", False
  327. End Sub
  328. Sub FirstButton_Click ()
  329.    Dim numbrows As Long         'number of rows
  330.    On Error GoTo GoFirstError
  331.    SetHourGlass Me
  332.    MsgBar "Going to first record", True
  333.    cGrid.SetFocus
  334.    cGrid.Row = 1
  335.    cGrid.Col = 0
  336.    'get current starting row in grid
  337.    If cGrid.Text <> "1" Then
  338.      FDS.Close
  339. '     Set FDS = gCurrentDB.CreateDynaset(FDS.Name)
  340.      Set FDS = gCurrentDB.CreateSnapshot(FDS.Name)
  341.      FNumbRows = GetNumbRecsSS(FDS)
  342.      If FNumbRows > gwMaxGridRows Then
  343.        numbrows = gwMaxGridRows
  344.        FCurrentRow = numbrows
  345.      Else
  346.        numbrows = FNumbRows
  347.      End If
  348.      If LoadGrid(cGrid, FDS, FDynSt, numbrows, 0) = False Then
  349.        Unload Me
  350.        fQuery.Show
  351.        Exit Sub
  352.      End If
  353.   End If
  354.   cGrid.Col = 1
  355.   SendKeys "{Home}"
  356.   GoTo GoFirstEnd
  357. GoFirstError:
  358.   ShowError
  359.   Resume GoFirstEnd
  360. GoFirstEnd:
  361.   ResetMouse Me
  362.   MsgBar "", False
  363. End Sub
  364. Sub Form_Load ()
  365.    Dim t As TableDef       'local table structure
  366.    Dim sp As Integer       'starting point of table name
  367.    Dim ep As Integer       'ending point of table name
  368.    Dim wh As String        'where clause
  369.    Dim i As Integer, j As Integer
  370.    Dim fn As String        'field name
  371.    Dim rc As Integer       'record count
  372.    Dim numbrows As Long    'local number of rows
  373.    Dim ss As snapshot
  374.    Dim ds As String
  375.    gwMaxGridRows = 250
  376.    On Error GoTo DynasetErr
  377.    SetHourGlass Me
  378.    MsgBar "Opening Dynaset", True
  379.    If gfFROMSQL = True Then
  380.      ds = fQuery!cCriteria
  381.         If gfFROMSQL Then
  382.             gstDynaString = fQuery!cCriteria
  383.         End If
  384.    Else
  385.        ds = gstDynaString
  386.    End If
  387.    'attemp to open the dynaset
  388.    Set FDS = gCurrentDB.CreateSnapshot(ds)
  389.    'parse off table name to store in global gstTblName
  390.    wh = ""
  391.    sp = InStr(1, UCase(ds), "FROM")
  392.    If sp > 0 Then
  393.      'must be a "select from" statement
  394.      sp = sp + 5
  395.      For ep = sp To Len(ds)
  396.        'search for a space or the end of ds
  397.        If Mid$(ds, ep, 1) = " " Then
  398.          'get where clause if there is one
  399.          wh = Mid$(ds, sp, Len(ds) - sp + 1)
  400.          Exit For
  401.        End If
  402.      Next
  403.      FTblname = UCase(Mid$(ds, sp, ep - sp))
  404.      If wh = "" Then wh = FTblname
  405.    Else
  406.      'must be a table name only
  407.      FTblname = UCase(ds)
  408.      
  409.      wh = FTblname
  410.    End If
  411.    gTblname = FTblname
  412.    FDynaString = wh
  413.    'show the first record
  414.    FNumbRows = GetNumbRecsSS(FDS)          'query numb of recs
  415.    If FNumbRows = -1 Then
  416.      'error occurred but go on anyway
  417.      'because row count is non-critical
  418.      Caption = "SnapShot: " + FTblname
  419.      numbrows = gwMaxGridRows
  420.      FCurrentRow = numbrows
  421.    ElseIf FNumbRows = 0 Then
  422.      Beep
  423.      MsgBox "No Records found!", 48
  424.      ResetMouse Me
  425.      Unload Me
  426.      fQuery.Show
  427.      Exit Sub
  428.    ElseIf FNumbRows > gwMaxGridRows Then
  429.      Caption = "SnapShot: " + FTblname + " [" + CStr(FNumbRows) + " total rows]"
  430.      numbrows = gwMaxGridRows
  431.      FCurrentRow = numbrows
  432.    Else
  433.      numbrows = FNumbRows
  434.      Caption = "SnapShot: " + FTblname + " [" + CStr(FNumbRows) + " rows]"
  435.    End If
  436.    If LoadGrid(cGrid, FDS, ds, numbrows, 0) = False Then
  437.      Unload Me
  438.      fQuery.Show
  439.      Exit Sub
  440.    End If
  441.    Height = 3800 + numbrows * 20
  442.    Width = 5450 + gsumcolwid / 2
  443.    'Left = 1000
  444.    'Top = 1000
  445.    Me.Left = (screen.Width - Me.Width) / 2
  446.    Me.Top = (screen.Height - Me.Height) / 2
  447.     Me.Show
  448.     fQuery.Hide
  449.    GoTo OkayEnd
  450. DynasetErr:
  451.    ShowError
  452.    ResetMouse Me
  453.    MsgBar "", False
  454.    Unload Me
  455.    fQuery.Show
  456.    Exit Sub
  457.    Resume OkayEnd
  458. OkayEnd:
  459.    ResetMouse Me
  460.    MsgBar "", False
  461. End Sub
  462. Sub Form_Resize ()
  463.   On Error Resume Next
  464.   'resize grid to window
  465.   If WindowState <> 1 Then   'not minimized
  466.     cGrid.Height = Height - 900
  467.     cGrid.Width = Width - 100
  468.   End If
  469. End Sub
  470. Sub Form_Unload (Cancel As Integer)
  471.   On Error Resume Next
  472.   'unload the find form
  473.   Unload FFindForm
  474.   'close the associated dynaset
  475.   FDS.Close
  476.   MsgBar "", False
  477. End Sub
  478. Sub MoreButton_Click ()
  479.   Dim ret As Integer   'return value from loadgrid
  480.   On Error Resume Next
  481.   MsgBar "Getting more records", True
  482.   If FDS.EOF <> True Then
  483.     SetHourGlass Me
  484.     ret = LoadGrid(cGrid, FDS, FDynSt, gwMaxGridRows, FCurrentRow)
  485.     If ret = False Then
  486.       'failed so bail out of form
  487.       FDS.Close
  488.       Unload Me
  489.       fQuery.Show
  490.     End If
  491.     'set new current row
  492.     FCurrentRow = FCurrentRow + ret
  493.     ResetMouse Me
  494.     Else
  495.     MsgBox "All Records Loaded!", 48
  496.   End If
  497.   MsgBar "", False
  498. End Sub
  499. Sub NextButton_Click ()
  500.    Dim c As Integer      'current column
  501.    On Error GoTo GoNextError
  502.    c = cGrid.Col
  503.    cGrid.Col = 0
  504.    If cGrid.Text = "" Then
  505.      Beep
  506.    ElseIf cGrid.Row = gwMaxGridRows Then
  507.      MoreButton_Click
  508.    Else
  509.      cGrid.SetFocus
  510.      SendKeys "{Down}"
  511.    End If
  512.    cGrid.Col = c
  513.    GoTo GoNextEnd
  514. GoNextError:
  515.    ShowError
  516.    Resume GoNextEnd
  517. GoNextEnd:
  518. End Sub
  519. 'needed for multi-user situations so
  520. 'new records can be viewed imediately
  521. Sub RefreshButton_Click ()
  522.    Dim numbrows As Long
  523.    On Error GoTo RefreshError
  524.    MsgBar "Reopening Dynaset", True
  525.    SetHourGlass Me
  526. '   Set FDS = gCurrentDB.CreateDynaset(FDS.Name)
  527.    Set FDS = gCurrentDB.CreateSnapshot(FDS.Name)
  528.    FNumbRows = GetNumbRecsSS(FDS)
  529.    If FNumbRows = -1 Then
  530.      'error occurred but go on anyway
  531.      'because row count is non-critical
  532.      Caption = "Dynaset: " + FTblname
  533.      numbrows = gwMaxGridRows
  534.      FCurrentRow = numbrows
  535.    ElseIf FNumbRows = 0 Then
  536.      Beep
  537.      MsgBox "No Records found!", 48
  538.      ResetMouse Me
  539.      Unload Me
  540.      fQuery.Show
  541.    ElseIf FNumbRows > gwMaxGridRows Then
  542.      Caption = "Dynaset: " + FTblname + " [" + CStr(FNumbRows) + " total rows]"
  543.      numbrows = gwMaxGridRows
  544.      FCurrentRow = numbrows
  545.    Else
  546.      numbrows = FNumbRows
  547.      Caption = "Dynaset: " + FTblname + " [" + CStr(FNumbRows) + " rows]"
  548.    End If
  549.    If LoadGrid(cGrid, FDS, FDynSt, numbrows, 0) = False Then
  550.      Unload Me
  551.      fQuery.Show
  552.      Exit Sub
  553.    End If
  554.   GoTo RefreshEnd
  555. RefreshError:
  556.   ShowError
  557.   Resume RefreshEnd
  558. RefreshEnd:
  559.   ResetMouse Me
  560.   MsgBar "", False
  561. End Sub
  562. Sub SortButton_Click ()
  563.   On Error GoTo SortErr
  564. '  Dim ds1 As dynaset, ds2 As dynaset
  565.   Dim ds1 As snapshot, ds2 As snapshot
  566.   'Dim gSortStr As String
  567.   Dim numbrows As Long    'local number of rows
  568.   Set ds1 = FDS            'save the dynaset
  569.    Dim i As Integer, r As Integer, c As Integer
  570.    'On Error GoTo FindErr
  571.    'load the column names into the filter form
  572.    'the 1st time it is loaded
  573.    fSort.cFieldList.Clear
  574.      r = cGrid.Row
  575.      c = cGrid.Col
  576.      cGrid.Row = 0
  577.      cGrid.Col = 0
  578.      For i = 1 To cGrid.Cols - 1
  579.        cGrid.Col = cGrid.Col + 1
  580.        fSort.cFieldList.AddItem cGrid.Text
  581.      Next
  582.      cGrid.Row = r
  583.      cGrid.Col = c
  584.   fSort.Show MODAL
  585.   'gSortStr = InputBox("Enter Sort Column:")
  586.   If gSortStr = "" Then Exit Sub
  587.   FDS.Sort = gSortStr
  588. '  Set ds2 = FDS.CreateDynaset()            'establish the Sort
  589.   Set ds2 = FDS.CreateSnapshot()            'establish the Sort
  590.   Set FDS = ds2            'assign back to original dynaset object
  591.   'everything must be okay so redisplay form on 1st record
  592.   FNumbRows = GetNumbRecsSS(FDS)          'query numb of recs
  593.    If FNumbRows = -1 Then
  594.      'error occurred but go on anyway
  595.      'because row count is non-critical
  596.      Caption = "Dynaset: " + FTblname
  597.      numbrows = gwMaxGridRows
  598.      FCurrentRow = numbrows
  599.    ElseIf FNumbRows = 0 Then
  600.      Beep
  601.      MsgBox "No Records found!", 48
  602.      ResetMouse Me
  603.      Unload Me
  604.      fQuery.Show
  605.      Exit Sub
  606.    ElseIf FNumbRows > gwMaxGridRows Then
  607.      Caption = "Dynaset: " + FTblname + " [" + CStr(FNumbRows) + " total rows]"
  608.      numbrows = gwMaxGridRows
  609.      FCurrentRow = numbrows
  610.    Else
  611.      numbrows = FNumbRows
  612.      Caption = "Dynaset: " + FTblname + " [" + CStr(FNumbRows) + " rows]"
  613.    End If
  614.   If LoadGrid(cGrid, FDS, FDynSt, numbrows, 0) = False Then
  615.     Unload Me
  616.     fQuery.Show
  617.     Exit Sub
  618.   End If
  619.   GoTo SortEnd
  620. SortErr:
  621.   ShowError
  622.   Set FDS = ds1            're-assign back to original
  623.   Resume SortEnd
  624. SortEnd:
  625. End Sub
  626.